<%@ page contentType="text/html; charset=utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/resource/css/default.css" />
		<link rel="stylesheet" type="text/css" href="${contextPath}/resource/tree/zTreeStyle/zTreeStyle.css" />
		<script type="text/javascript" src="${contextPath}/resource/tree/jquery-1.4.2.js"></script>
		<script type="text/javascript" src="${contextPath}/resource/tree/jquery.ztree-2.6.js"></script>
		<script language="JavaScript">
var zTree1;
var setting;
setting = {
	isSimpleData : true,
	treeNodeKey : "id",
	treeNodeParentKey : "pId",
	showIcon : false,
	checkable : true,
	checkStyle : "radio",
	checkRadioType : "all",
	callback : {
		change : zTreeOnChange
	}
};

$(document).ready(function() {
	refreshTree();
	getCheckedrefreshTree();
});

var treeDb = ${jsonTree};
//设置单选框被选中的值 
var checkValue = '${user.blngOrgNo}';
for(var i=0;i<treeDb.length;i++){
	if(treeDb[i].id == checkValue){
		treeDb[i].checked = true;
	}
}
	function zTreeOnChange(event, treeId, treeNode) {
		getCheckedNodesLength();
	}
	function refreshTree() {
		
		zTree1 = $("#radioAgencyId").zTree(setting, treeDb);
		getCheckedNodesLength();
	}

	function getCheckedNodesLength() {
		var tmp = zTree1.getCheckedNodes(true);
		if(tmp.length>0){
		   document.getElementById("user.blngOrgNo").value =tmp[0].id;
		}
	}

var treeDb1  = ${jsonTree};
//取得多选框数中被选中的值，并设置被选中 
var checkValues =${user.brwsOrgNo}+"";
var butgrpVales={"":""};
if(checkValues != null && checkValues != "" ){
	var butts =checkValues.split("");
	for(var i=0;i<butts.length;i++){
		var flg = butts[i];
		if(flg=="1"){
			var sval ="1";
			for(var j=butts.length-i;j>1;j--){
				sval = sval+"0";
			}
			butgrpVales[sval]=sval;
		}
	}
}
for(var i=0;i<treeDb1.length;i++){
	if(treeDb1[i].arGrp == butgrpVales[treeDb1[i].arGrp]){
		treeDb1[i].checked = true;
	}
}


var zTreeCheck;
	var settingCheck;
		settingCheck = {
		isSimpleData: true,
		treeNodeKey: "id",
		treeNodeParentKey: "pId",
        showIcon :false,
			checkable: true,
			callback: {
				change:	zTreeOnChangeCheck_lh
			}
		};

	
	function zTreeOnChangeCheck_lh(event, treeId, treeNode) {
		getCheckedNodesLength_lh();
	}

	function getCheckBoxType() {
		
		var type = { "Y":'s', "N":'s'};
		return type;
	}

	function getCheckedrefreshTree() {
		var checkType = getCheckBoxType();
		settingCheck.checkType = checkType;
		zTreeCheck = $("#checkViewagencyId").zTree(settingCheck, treeDb1);
	}

	function getCheckedNodesLength_lh() {
		var tmp = zTreeCheck.getCheckedNodes();
	    var viewagencyIds="" ;
		for(var i = 0;i<tmp.length;i++){
		   if(i==tmp.length-1){
		   viewagencyIds +=tmp[i].arGrp;
		   }else{
		   viewagencyIds +=tmp[i].arGrp+",";
		   }
		}
		document.getElementById("user.brwsOrgNo").value =viewagencyIds;
	}
</script>
	</head>
	<body>
			<table class="menu_table">
				<tr>
					<th>
						<a href="userAction_list.do">用户管理</a>&gt;&gt;新增用户
					</th>
				</tr>
			</table>
			<div class="listtable" align="right">
			<s:if test="buttonGrpMap['edit']">
				<input type="button" onclick="javascript:location='userAction_edit.do?user.userId=${user.userId}'" value="" class="edit_word_style"></input>
			</s:if>
			<input type="button" onclick="javascript:location='userAction_list.do'" value="" class="back_style">&nbsp;&nbsp;&nbsp;&nbsp;
			</div>	
			<div class="listtable">
				<div class="secondDiv">
					<table class="form_table">
						
						<tr>
							<th width="20%">
								登录名
							</th>
							<td>
								<s:text name="user.signNm" />
								
							</td>
							<th>
								状态
							</th>
							<td>
								<s:radio name="user.vldMrk" list="#{'1':'正常','0':'锁定'}"></s:radio>
								<span class="txtblue" id="resultadminUser">*</span>
							</td>
						</tr>
						<tr>
							<th>
								真实姓名
							</th>
							<td width="15%">
								<s:text name="user.userName" ></s:text>
							</td>
							<th width="20%">
								固定电话
							</th>
							<td width="35%">
								<s:text name="user.fxTel"/>
							</td>
						</tr>
						<tr>
							<th>
								移动电话
							</th>
							<td>
								<s:text name="user.mobl" />
							</td>
							<th>
								电子邮件
							</th>
							<td>
								<s:text name="user.email" />
							</td>
						</tr>
						<tr>
							<th>
								登录纬度
							</th>
							<td>
								<s:property value="user.wellat" />
							</td>
							<th>
								登录经度
							</th>
							<td><s:property value="user.wellog" />
							</td>
						</tr>
						<tr>
							<th>
								所属角色
							</th>
							<td colspan="3">
								<s:checkboxlist list="roleMap" name="roleIdValues"></s:checkboxlist>
								<span class="txtblue" id="resultadminUser">*</span>
							</td>
						</tr>
						<tr>
							<th>
								所属机构
							</th>
							<s:hidden name="user.blngOrgNo" id="user.blngOrgNo"></s:hidden>
							<td>
								<div class="zTreeDemoBackground">
									<ul id="radioAgencyId" class="tree"></ul>
								</div>
							</td>
							<th>
								浏览机构信息
							</th>
							<td>
								<div class="zTreeDemoBackground">
									<ul id="checkViewagencyId" class="tree"></ul>
								</div>
							</td>
						</tr>
						<tr>
							<th>
								描述
							</th>
							<td colspan="3">
								<s:text name="user.dtlDesc" ></s:text>
							</td>
						</tr>
					</table>
				</div>
			</div>
	</body>
</html>
